<!--- begin frm_modify.cfm --->
#l#cfsilent>
<cfoutput>
<cfif is_identity eq 'Y'>#l#cfparam name="attributes.#column_name#" <cfif data_type eq "int"> default="0"</cfif> />

#l#cfscript>
	actionPage = 'act_update.cfm';
	myAct = 'Update';
	if (val(attributes.#column_name#) eq 0) {
		actionPage = 'act_create.cfm';
		myAct = 'New';
	}
#l#/cfscript>
</cfif></cfoutput>
#l#cfinclude template="qry.cfm" />

#l#!--- reference tables ---><cfsilent>
<cfquery name="rsRefQry" dbtype="query">
	SELECT 
		table_name
		, ref_table_name
		, column_name
	FROM
		rsRef
	WHERE
		table_name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#rs.Table_Name#" />
</cfquery>
<cfset lstRefColumn = ValueList(rsRefQry.column_name) />
<cfset lstRefTable = ValueList(rsRefQry.ref_table_name) />
</cfsilent>
<cfloop query="rsRefQry">
#l#cfinclude template="../#tabName(rsRefQry.ref_table_name)#/qry.cfm" /></cfloop>

#l#cfparam name="actionPage" default="" />
#l#cfparam name="myAct" default="" />
#l#/cfsilent>

#l#form method="post" name="form_#tabName(Table_Name)#" id="form_#tabName(Table_Name)#" action="#l#cfoutput>##actionPage###l#/cfoutput>" onSubmit="return checkForm(this);">	
<cfoutput><cfif is_identity eq 'Y'>
#l#input type="hidden" name="#column_name#" id="#column_name#" value="#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>">
</cfif></cfoutput>

	#l#table class="userInput">
		#l#caption>
			#l#cfoutput>##myAct###l#/cfoutput> #dspFormat(Table_Name)#
		#l#/caption>
		#l#tbody>
			
			<cfoutput>
			<cfif is_identity neq 'Y'>
				<cfswitch expression="#data_type#">
				
					<cfcase value="varchar,char,int,smallint,decimal">
						#l#tr>
							#l#td>
								#l#label for="#column_name#">#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								<cfif ListFind(lstRefColumn,column_name) gt 0>
									<!--References another table... -->
									<cfsilent>
									<cfscript>
										listPos = ListFind(lstRefColumn,column_name);
										refTable = tabName(ListGetAt(lstRefTable,listPos));
									</cfscript>
									</cfsilent><!--- found in reference query so make a drop-down list --->
									#l#select name="#column_name#" id="#column_name#"
										<cfif is_nullable eq "N">required="true"</cfif>>
										#l#option value="">- All -#l#/option>
										#l#cfoutput query="rs_#refTable#">
											#l#option value="##rs_#refTable#.#column_name###" #l#cfif (isDefined("rs_#tabName(Table_Name)#.#column_name#") AND rs_#refTable#.#column_name# EQ rs_#tabName(Table_Name)#.#column_name#)>selected="selected"#l#/cfif>>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_name')####l#cfcatch>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_desc')####l#cfcatch>##rs_#refTable#.#column_name####l#/cfcatch>#l#/cftry>#l#/cfcatch>#l#/cftry>#l#/option>
										#l#/cfoutput>
									#l#/select>
									<cfelse><!--- simple input --->
									#l#input name="#column_name#" id="#column_name#" 
										<cfif is_nullable eq "N">required="true"</cfif>
										<cfif data_type CONTAINS "int">onKeyPress="return allowChar(this,numChars,event);"</cfif>
										<cfif column_name CONTAINS 'phone' 
												OR column_name CONTAINS 'fax'>onKeyPress="return allowChar(this,numChars,event);"</cfif>
										type="<cfif column_name CONTAINS 'password' 
												OR column_name CONTAINS 'pwd'>password<cfelse>text</cfif>" value="#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>"
										size="#min(32,length)#" maxlength="#length#" />
								</cfif>
							#l#/td>
						#l#/tr>
					</cfcase>
				
					<cfcase value="datetime,smalldatetime">
						#l#tr>
							#l#td>
								#l#label for="#column_name#">#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								#l#input name="#column_name#" id="#column_name#" 
									onKeyPress="return allowChar(this,dateChars,event);"
									type="text" value="#l#cfoutput>##LSDateFormat(rs_#tabName(Table_Name)#.#column_name#,request.dtFrmt)###l#/cfoutput>"
									size="10" maxlength="10" />
							#l#/td>
						#l#/tr>
					</cfcase>
					
					<cfcase value="text,ntext">
						#l#tr>
							#l#td>
								#l#label for="#column_name#">#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								#l#textarea name="#column_name#" id="#column_name#" 
									class="fck basic">#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>#l#/textarea>
							#l#/td>
						#l#/tr>
					</cfcase>
					
					<cfcase value="bit">
						#l#tr>
							#l#td />
							#l#td>
								#l#label for="#column_name#" class="inline">
									#l#input type="checkbox" name="#column_name#" id="#column_name#" 
										#l#cfif val(##rs_#tabName(Table_Name)#.#column_name###)>checked#l#/cfif>
										/>
								#dspFormat(column_name)##l#/label>
							#l#/td>
						#l#/tr>
					</cfcase>
					
					<cfdefaultcase>
						#data_type#
					</cfdefaultcase>
				</cfswitch>
			</cfif>
			</cfoutput>
			
		#l#/tbody>
		#l#tfoot>
			#l#tr>
				#l#td />
				#l#td>
					#l#input type="submit" value="Submit" class="button" accesskey="S" />
					#l#input type="button" value="Cancel" class="button" onclick="cancelModify()" />
				#l#/td>
			#l#/tr>
		#l#/tfoot>
	#l#/table>
#l#/form>
<!--- end frm_modify.cfm --->